home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2000 February / Macworld (2000-02).dmg / Shareware World / Comms & Internet / Flex-Able 1.0 / FADocs / session.able < prev    next >
Text File  |  1999-12-07  |  2KB  |  65 lines

  1. <html>
  2.     <head>
  3.         <link rel=stylesheet type="text/css" HREF="fa.css">
  4.         <title>Flex-Able: Sessions</title>
  5.     </head>
  6. <body>
  7.  
  8. <DIV CLASS="topic">Sessions</DIV>
  9. <p><br>
  10. <p><br>
  11.  
  12.  
  13. To activate a session, simply use the
  14. get_session command and store the result:<br> <ul>
  15.  
  16. <:set someVar <:get_session>> </ul> If the browser already has a
  17. cookie that matches an active session, then the data for that session is
  18. made available through the given variable (in this case someVar) as an
  19. associative array.  If the browser doesn't have a cookie, or that cookie
  20. doesn't match an active session, a new session array is created and the
  21. browser is sent a "Set-Cookie" field as part of the response.<br>
  22.  
  23. There are some special members of the session array:<p>
  24.  
  25. <ul>
  26. <li><b>$timeout</b><br><ul>how long the session will live in spite of
  27. inactivity on the browser's part.  Measured in minutes.</ul>
  28. <li><b>$id</b><br><ul>the session ID, which is also the cookie value sent to
  29. the browser for identification</ul> <li><b>$lastuse</b><br><ul>a big number
  30. that is used internally to keep track of how long it has been since the
  31. session was used</ul> </ul> If you wish to remove session data from memory,
  32. use:<br> <ul> <:end_session> </ul> Keep in mind that if you have
  33. already used the <:get_session> command, the variable you assigned the
  34. session data to is still good. However, if you overwrite that variable with
  35. something else, then the session data will be removed from memory.
  36. Otherwise, the session data won't be deleted until the connection ends.
  37.  
  38. </ul>
  39.  
  40.  
  41. <!-- First, read the form data --> <:set form <:read_form>>
  42.  
  43. <!-- Either set the session and get new data, or end it --> <:ifempty
  44. form["Logout"]> <:set sdata <:get_session>> <:require form["new name"] form["new
  45. value"]> <:set sdata[form["new name"]] form["new value"]> <:/require>
  46. <:else> <!-- delete the session --> <:end_session> <:/ifempty>
  47.  
  48.  
  49. <h2>Current Session Variables</h2>
  50.  
  51. <table> <:foreach name value sdata> <tr> <th align=right><:echo name></th>
  52. <td aligh=left><:echo value></td> </tr><:/foreach> </table><P>
  53.  
  54.  
  55. <h2>Add Another Variable</h2> <form action="session.able" method=POST> Name:
  56. <input type=text name="new name"><br> Value: <input type=text name="new
  57. value"><br> <input type=submit value="add"> <input type=submit name="Logout"
  58. value="End Session"> </form><P>
  59. <hr>
  60. <A HREF="default.html" CLASS="back">back to Contents</A>/<A HREF="quickstart.html" CLASS="back">back to Quick Start</A>
  61. </body>
  62. </html> 
  63.  
  64.  
  65.